package com.weimei.conversionTreasure.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.http.entity.TabOneEntity;
import com.weimei.conversionTreasure.utils.GlideHandler;

public class MarketAdapter extends BaseQuickAdapter<TabOneEntity, BaseViewHolder> {
    public MarketAdapter() {
        super(R.layout.item_market);
    }

    private int mIndex = -1;
    private int mFlag = 0;

    public void setSel(int index){
        mIndex = index;
        notifyDataSetChanged();
    }



    @Override
    protected void convert(@NonNull BaseViewHolder holder, TabOneEntity tabOneEntity) {
        holder.setText(R.id.name,tabOneEntity.tabStr);

        holder.setImageResource(R.id.iv,tabOneEntity.ImgRes);

        if (mIndex == getItemPosition(tabOneEntity)){
            holder.setImageResource(R.id.iv,tabOneEntity.selImgRes);
            holder.setTextColor(R.id.name, Color.parseColor("#2B2E38"));
        }else {
            holder.setImageResource(R.id.iv,tabOneEntity.ImgRes);
            holder.setTextColor(R.id.name, Color.parseColor("#5A5D68"));
        }

    }
}
